<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button @click="$emit('change','List')" size="mini">返回</el-button>
        <el-button type="primary" @click="save" size="mini">保存</el-button>
      </el-col>
    </el-row>
    <el-form ref="form" :rules="rules" :model="form" label-width="120px">
      <el-row :gutter="20">  
        <el-col :span="6">
          <el-form-item label="登记人" prop="q">
            <el-select style="width: 100%;" v-model="form.w" :readonly="true" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="填报日期" prop="q">
            <el-date-picker
              v-model="form.q"
              type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属年份" prop="q">
            <el-input v-model="form.q" :readonly="isReadOnly" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属月份" prop="q">
            <el-input v-model="form.q" :readonly="isReadOnly" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="客户" prop="q">
            <el-select style="width: 100%;" v-model="form.w" :readonly="isReadOnly" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="上期累计收入" prop="q">
            <el-input v-model="form.q" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="本期累计收入" prop="q">
            <el-input v-model="form.q" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="本月收入" prop="q">
            <el-input v-model="form.q" :readonly="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="本期累计增值税" prop="q">
            <el-input v-model="form.q" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="上期累计增值税" prop="q">
            <el-input v-model="form.q" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="本月税金合计" prop="q">
            <el-input v-model="form.q" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="本期税金合计" prop="q">
            <el-select style="width: 100%;" v-model="form.w" :readonly="isReadOnly" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="房屋租赁面积" prop="q">
            <el-input v-model="form.q" :readonly="isReadOnly" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="备注" prop="q">
            <el-input v-model="form.q" :readonly="isReadOnly" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table style="margin-top: 40px;" v-loading="loading" :data="list">
      <el-table-column label="税费名称" prop="roleName" />
      <el-table-column label="上期累计税金" prop="roleName" />
      <el-table-column label="本期累计税金" prop="roleName" />
      <el-table-column label="本月税金" prop="roleName">
        <template slot-scope="scope">
          <el-input v-model="scope.row.q" oninput="value=value.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')" />
        </template>
      </el-table-column>
    </el-table>
    <!-- 打印对话框 -->
    <el-dialog title="打印" :visible.sync="printOpen" width="800px" append-to-body>
      <el-row>
        <el-col style="text-align: center;">XX有限公司物料入库表</el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">单据号：DJH323242345</el-col>
        <el-col :span="8">日期：2023-11-11</el-col>
        <el-col :span="8">物料仓库：XX仓库</el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">采购人：张三</el-col>
        <el-col :span="8">制单人：李四</el-col>
        <el-col :span="8">备注：</el-col>
      </el-row>
      <el-table :data="printList">
        <el-table-column label="类别" prop="roleName" />
        <el-table-column label="物料名称" prop="roleKey"  />
        <el-table-column label="规格" prop="roleSort" />
        <el-table-column label="数量" prop="roleSort" width="100" />
        <el-table-column label="单位" prop="roleSort" width="100" />
        <el-table-column label="单价" prop="roleSort" />
        <el-table-column label="金额" prop="roleSort" />
        <el-table-column label="用途" prop="roleSort" width="100" />
      </el-table>

      <pagination
        v-show="printTotal>0"
        :total="printTotal"
        :page.sync="printParams.pageNum"
        :limit.sync="printParams.pageSize"
        @pagination="getPrintList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="printSubmit">确 定</el-button>
        <el-button @click="printOpen=false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: {
    type: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      ids: [],
      // 是否只读
      isReadOnly: false,
      // 下拉数据
      options: [],
      loading: false,
      // 表格数据
      list: [],
      rules: {
        q: [{ required: true, message: '请输入', trigger: 'blur' }],
        w: [{ required: true, message: '请选择', trigger: 'change' }],
        e: [{ required: true, message: '请输入', trigger: 'blur' }],
        r: [{ required: true, message: '请输入', trigger: 'blur' }],
      },
      form: {},
      // 打印
      printOpen: false,
      printList: [],
      printTotal: 0,
      printParams: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  created() {
    if (this.type === '查看') {
      this.isReadOnly = true
    }
  },
  methods: {
    // 打印
    getPrintList() {

    },
    handlePrint() {
      this.printOpen = true
    },
    printSubmit() {

    }
  }
}
</script>